{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "from utils import *\n",
    "from constant import *"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def dateBetween(begin_date=\"2007-01-01\",end_date=\"2017-05-01\"):\n",
    "    return (data_df[\"date\"] > begin_date) & (data_df[\"date\"] < end_date)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def isValid(sub_df):\n",
    "    if len(sub_df) == 0:\n",
    "        return True\n",
    "    sub_df = sub_df.sort_values(\"minute\")\n",
    "    sub_df = sub_df.groupby(\"date\").first()\n",
    "    win_df = sub_df[sub_df[\"change\"] > 1.0]\n",
    "    win_ratio = float(len(win_df))/len(sub_df)\n",
    "    if len(sub_df) < 10:\n",
    "        return sub_df.change.mean() > 1.015 and win_ratio >= 0.5\n",
    "    else:\n",
    "#     print win_ratio,sub_df.change.mean()\n",
    "        return sub_df.change.mean() > 1.02 and win_ratio > 0.6"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def checkFilter(filter_key):\n",
    "    to_filter = getFilter(filter_key,True) & ~yz2\n",
    "    sub_df1 = data_df[to_filter & dateBetween(end_date=\"2015-06-01\")]\n",
    "    sub_df2 = data_df[to_filter & dateBetween(begin_date=\"2015-06-01\")]\n",
    "    return isValid(sub_df1) and isValid(sub_df2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/usr/local/lib/python2.7/site-packages/ipykernel/__main__.py:3: UserWarning: Boolean Series key will be reindexed to match DataFrame index.\n",
      "  app.launch_new_instance()\n",
      "/usr/local/lib/python2.7/site-packages/ipykernel/__main__.py:4: UserWarning: Boolean Series key will be reindexed to match DataFrame index.\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['~speedup1-~jump1-speedup2-foot0-foot1-~small_capq-2']\n",
      "['~foot1-small_volume-yz0-3', 'jump1-~foot1-minute-small_volume-yz0-3', '~speedup1-jump1-~speedup2-~jump2-~foot1-~foot2-minute-~small_volume-~opentop0-~opentop1-3', 'jump2-foot0-~foot1-foot2-small_capq-small_volume-3', 'opentop2-~speedup1-jump1-~foot1-~foot2-~opentop1-3', '~opentop2-speedup1-foot0-~foot2-~small_capq-small_volume-3', 'opentop2-jump1-jump2-foot1-minute-~opentop1-3', '~opentop2-jump2-foot0-~foot1-~foot2-~small_capq-small_volume-3']\n",
      "['~opentop2-~speedup1-~foot2-~isnew-~small_capq-minute-small_volume-~opentop1-4', '~speedup1-~jump2-~foot1-small_capq-small_volume-top0-4', '~speedup1-jump1-jump2-~foot1-foot2-small_volume-4', '~opentop2-~speedup1-jump1-~speedup2-~foot1-~foot2-~small_capq-minute-4', '~opentop2-~speedup1-jump1-~speedup2-~foot1-minute-small_volume-4', '~opentop2-~speedup1-jump1-foot0-~foot1-minute-small_volume-4', '~opentop2-~jump1-speedup2-small_capq-small_volume-~opentop1-4', '~speedup1-foot0-~foot1-foot2-small_volume-4', '~speedup1-~jump2-~foot1-small_capq-minute-small_volume-4', '~opentop2-~foot1-small_capq-minute-small_volume-yz0-4', '~opentop2-~speedup2-~foot0-small_capq-minute-small_volume-~opentop0-top0-4', '~opentop2-jump1-minute-small_volume-~yz1-opentop1-4', '~opentop2-jump2-foot2-small_capq-small_volume-4', '~opentop2-speedup2-foot2-small_capq-minute-4']\n",
      "['jump1-~speedup2-~foot2-~isnew-minute-~yz1-opentop1-5']\n",
      "['~opentop2-jump1-small_capq-minute-small_volume-6', '~opentop2-foot0-small_capq-minute-6']\n",
      "[]\n"
     ]
    }
   ],
   "source": [
    "for filters in filterss:\n",
    "    each_filters = []\n",
    "    for filter_key in filters:\n",
    "        if checkFilter(filter_key):\n",
    "            each_filters.append(filter_key)\n",
    "    print each_filters"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.789473684211 1.04352019897\n",
      "0.571428571429 1.02378899346\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/usr/local/lib/python2.7/site-packages/ipykernel/__main__.py:3: UserWarning: Boolean Series key will be reindexed to match DataFrame index.\n",
      "  app.launch_new_instance()\n",
      "/usr/local/lib/python2.7/site-packages/ipykernel/__main__.py:4: UserWarning: Boolean Series key will be reindexed to match DataFrame index.\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "checkFilter('jump1-~speedup2-~foot2-~isnew-minute-~yz1-opentop1-5')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/usr/local/lib/python2.7/site-packages/ipykernel/__main__.py:2: UserWarning: Boolean Series key will be reindexed to match DataFrame index.\n",
      "  from ipykernel import kernelapp as app\n"
     ]
    }
   ],
   "source": [
    "to_filter = getFilter('jump1-~speedup2-~foot2-~isnew-minute-~yz1-opentop1-5',True) & ~yz2\n",
    "sub_df = data_df[to_filter]\n",
    "sub_df = sub_df.sort_values(\"minute\")\n",
    "sub_df = sub_df.groupby(\"date\").first()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>change</th>\n",
       "      <th>stock</th>\n",
       "      <th>close0</th>\n",
       "      <th>high0</th>\n",
       "      <th>high_limit0</th>\n",
       "      <th>low0</th>\n",
       "      <th>open0</th>\n",
       "      <th>volume0</th>\n",
       "      <th>day0</th>\n",
       "      <th>close1</th>\n",
       "      <th>...</th>\n",
       "      <th>volume3</th>\n",
       "      <th>day3</th>\n",
       "      <th>minute_low</th>\n",
       "      <th>minute_volume</th>\n",
       "      <th>minute</th>\n",
       "      <th>recent</th>\n",
       "      <th>circap</th>\n",
       "      <th>isnew</th>\n",
       "      <th>capq</th>\n",
       "      <th>st</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2007-07-23 00:00:00</th>\n",
       "      <td>1.028160</td>\n",
       "      <td>600617.XSHG</td>\n",
       "      <td>12.62</td>\n",
       "      <td>12.62</td>\n",
       "      <td>12.62</td>\n",
       "      <td>11.70</td>\n",
       "      <td>12.30</td>\n",
       "      <td>3241958.0</td>\n",
       "      <td>103.0</td>\n",
       "      <td>13.88</td>\n",
       "      <td>...</td>\n",
       "      <td>3742741.0</td>\n",
       "      <td>106.0</td>\n",
       "      <td>8.38</td>\n",
       "      <td>531770.0</td>\n",
       "      <td>09:33:00</td>\n",
       "      <td>5.0</td>\n",
       "      <td>17.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.005155</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2008-12-18 00:00:00</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>600397.XSHG</td>\n",
       "      <td>4.31</td>\n",
       "      <td>4.31</td>\n",
       "      <td>4.31</td>\n",
       "      <td>4.31</td>\n",
       "      <td>4.31</td>\n",
       "      <td>5719937.0</td>\n",
       "      <td>448.0</td>\n",
       "      <td>4.74</td>\n",
       "      <td>...</td>\n",
       "      <td>22304664.0</td>\n",
       "      <td>451.0</td>\n",
       "      <td>2.07</td>\n",
       "      <td>18253344.0</td>\n",
       "      <td>09:47:00</td>\n",
       "      <td>5.0</td>\n",
       "      <td>509.5</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.154488</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2012-03-16 00:00:00</th>\n",
       "      <td>1.080107</td>\n",
       "      <td>600300.XSHG</td>\n",
       "      <td>6.19</td>\n",
       "      <td>6.19</td>\n",
       "      <td>6.19</td>\n",
       "      <td>5.82</td>\n",
       "      <td>6.19</td>\n",
       "      <td>51342868.0</td>\n",
       "      <td>66.0</td>\n",
       "      <td>6.81</td>\n",
       "      <td>...</td>\n",
       "      <td>188746336.0</td>\n",
       "      <td>69.0</td>\n",
       "      <td>6.83</td>\n",
       "      <td>11783973.0</td>\n",
       "      <td>10:31:00</td>\n",
       "      <td>5.0</td>\n",
       "      <td>2147.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.651001</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2012-04-24 00:00:00</th>\n",
       "      <td>1.087137</td>\n",
       "      <td>600606.XSHG</td>\n",
       "      <td>7.96</td>\n",
       "      <td>7.96</td>\n",
       "      <td>7.96</td>\n",
       "      <td>6.93</td>\n",
       "      <td>6.99</td>\n",
       "      <td>62181380.0</td>\n",
       "      <td>91.0</td>\n",
       "      <td>8.76</td>\n",
       "      <td>...</td>\n",
       "      <td>38214496.0</td>\n",
       "      <td>94.0</td>\n",
       "      <td>8.32</td>\n",
       "      <td>19988191.0</td>\n",
       "      <td>09:35:00</td>\n",
       "      <td>5.0</td>\n",
       "      <td>1801.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.546089</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2012-08-08 00:00:00</th>\n",
       "      <td>0.960000</td>\n",
       "      <td>002070.XSHE</td>\n",
       "      <td>9.30</td>\n",
       "      <td>9.30</td>\n",
       "      <td>9.30</td>\n",
       "      <td>8.60</td>\n",
       "      <td>8.68</td>\n",
       "      <td>29633210.0</td>\n",
       "      <td>147.0</td>\n",
       "      <td>10.23</td>\n",
       "      <td>...</td>\n",
       "      <td>33007452.0</td>\n",
       "      <td>150.0</td>\n",
       "      <td>8.65</td>\n",
       "      <td>0.0</td>\n",
       "      <td>09:30:00</td>\n",
       "      <td>5.0</td>\n",
       "      <td>1797.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.544876</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-08-29 00:00:00</th>\n",
       "      <td>1.209246</td>\n",
       "      <td>600018.XSHG</td>\n",
       "      <td>3.40</td>\n",
       "      <td>3.40</td>\n",
       "      <td>3.40</td>\n",
       "      <td>3.22</td>\n",
       "      <td>3.29</td>\n",
       "      <td>113849456.0</td>\n",
       "      <td>418.0</td>\n",
       "      <td>3.74</td>\n",
       "      <td>...</td>\n",
       "      <td>79742536.0</td>\n",
       "      <td>421.0</td>\n",
       "      <td>3.80</td>\n",
       "      <td>0.0</td>\n",
       "      <td>09:30:00</td>\n",
       "      <td>5.0</td>\n",
       "      <td>2444.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.741055</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2014-07-15 00:00:00</th>\n",
       "      <td>1.058366</td>\n",
       "      <td>002212.XSHE</td>\n",
       "      <td>6.37</td>\n",
       "      <td>6.37</td>\n",
       "      <td>6.37</td>\n",
       "      <td>6.37</td>\n",
       "      <td>6.37</td>\n",
       "      <td>4833381.0</td>\n",
       "      <td>628.0</td>\n",
       "      <td>7.01</td>\n",
       "      <td>...</td>\n",
       "      <td>82380808.0</td>\n",
       "      <td>631.0</td>\n",
       "      <td>7.48</td>\n",
       "      <td>0.0</td>\n",
       "      <td>09:30:00</td>\n",
       "      <td>5.0</td>\n",
       "      <td>850.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.257732</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2014-09-12 00:00:00</th>\n",
       "      <td>1.055061</td>\n",
       "      <td>300242.XSHE</td>\n",
       "      <td>25.06</td>\n",
       "      <td>25.06</td>\n",
       "      <td>25.06</td>\n",
       "      <td>25.06</td>\n",
       "      <td>25.06</td>\n",
       "      <td>779450.0</td>\n",
       "      <td>581.0</td>\n",
       "      <td>27.57</td>\n",
       "      <td>...</td>\n",
       "      <td>4093207.0</td>\n",
       "      <td>584.0</td>\n",
       "      <td>6.06</td>\n",
       "      <td>0.0</td>\n",
       "      <td>09:30:00</td>\n",
       "      <td>5.0</td>\n",
       "      <td>58.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.017586</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2014-09-19 00:00:00</th>\n",
       "      <td>1.058879</td>\n",
       "      <td>600260.XSHG</td>\n",
       "      <td>8.70</td>\n",
       "      <td>8.70</td>\n",
       "      <td>8.70</td>\n",
       "      <td>8.70</td>\n",
       "      <td>8.70</td>\n",
       "      <td>3975731.0</td>\n",
       "      <td>602.0</td>\n",
       "      <td>9.57</td>\n",
       "      <td>...</td>\n",
       "      <td>116226864.0</td>\n",
       "      <td>605.0</td>\n",
       "      <td>9.57</td>\n",
       "      <td>29786674.0</td>\n",
       "      <td>09:41:00</td>\n",
       "      <td>5.0</td>\n",
       "      <td>1696.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.514251</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-01-06 00:00:00</th>\n",
       "      <td>0.827023</td>\n",
       "      <td>600379.XSHG</td>\n",
       "      <td>12.66</td>\n",
       "      <td>12.66</td>\n",
       "      <td>12.66</td>\n",
       "      <td>12.66</td>\n",
       "      <td>12.66</td>\n",
       "      <td>479546.0</td>\n",
       "      <td>504.0</td>\n",
       "      <td>13.93</td>\n",
       "      <td>...</td>\n",
       "      <td>22347056.0</td>\n",
       "      <td>507.0</td>\n",
       "      <td>14.55</td>\n",
       "      <td>6670200.0</td>\n",
       "      <td>09:33:00</td>\n",
       "      <td>5.0</td>\n",
       "      <td>998.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.302608</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-11 00:00:00</th>\n",
       "      <td>1.073171</td>\n",
       "      <td>300081.XSHE</td>\n",
       "      <td>33.88</td>\n",
       "      <td>33.88</td>\n",
       "      <td>33.88</td>\n",
       "      <td>33.01</td>\n",
       "      <td>33.88</td>\n",
       "      <td>9387742.0</td>\n",
       "      <td>722.0</td>\n",
       "      <td>37.27</td>\n",
       "      <td>...</td>\n",
       "      <td>24823688.0</td>\n",
       "      <td>725.0</td>\n",
       "      <td>16.36</td>\n",
       "      <td>0.0</td>\n",
       "      <td>09:30:00</td>\n",
       "      <td>5.0</td>\n",
       "      <td>888.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.269254</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-04-03 00:00:00</th>\n",
       "      <td>1.045057</td>\n",
       "      <td>002356.XSHE</td>\n",
       "      <td>69.88</td>\n",
       "      <td>69.88</td>\n",
       "      <td>69.88</td>\n",
       "      <td>64.25</td>\n",
       "      <td>64.90</td>\n",
       "      <td>3867932.0</td>\n",
       "      <td>649.0</td>\n",
       "      <td>76.87</td>\n",
       "      <td>...</td>\n",
       "      <td>9805463.0</td>\n",
       "      <td>652.0</td>\n",
       "      <td>26.76</td>\n",
       "      <td>3074653.0</td>\n",
       "      <td>09:33:00</td>\n",
       "      <td>5.0</td>\n",
       "      <td>1474.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.446938</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-04-13 00:00:00</th>\n",
       "      <td>1.051472</td>\n",
       "      <td>300388.XSHE</td>\n",
       "      <td>82.53</td>\n",
       "      <td>82.53</td>\n",
       "      <td>82.53</td>\n",
       "      <td>82.53</td>\n",
       "      <td>82.53</td>\n",
       "      <td>234151.0</td>\n",
       "      <td>163.0</td>\n",
       "      <td>90.78</td>\n",
       "      <td>...</td>\n",
       "      <td>11206967.0</td>\n",
       "      <td>166.0</td>\n",
       "      <td>32.10</td>\n",
       "      <td>2351834.0</td>\n",
       "      <td>09:31:00</td>\n",
       "      <td>5.0</td>\n",
       "      <td>281.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.085203</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-04-14 00:00:00</th>\n",
       "      <td>1.100000</td>\n",
       "      <td>000819.XSHE</td>\n",
       "      <td>40.16</td>\n",
       "      <td>40.16</td>\n",
       "      <td>40.16</td>\n",
       "      <td>36.23</td>\n",
       "      <td>36.23</td>\n",
       "      <td>5321822.0</td>\n",
       "      <td>810.0</td>\n",
       "      <td>44.18</td>\n",
       "      <td>...</td>\n",
       "      <td>18363148.0</td>\n",
       "      <td>813.0</td>\n",
       "      <td>43.96</td>\n",
       "      <td>0.0</td>\n",
       "      <td>09:30:00</td>\n",
       "      <td>5.0</td>\n",
       "      <td>1936.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.587022</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-04-30 00:00:00</th>\n",
       "      <td>1.074398</td>\n",
       "      <td>601669.XSHG</td>\n",
       "      <td>15.11</td>\n",
       "      <td>15.11</td>\n",
       "      <td>15.11</td>\n",
       "      <td>15.11</td>\n",
       "      <td>15.11</td>\n",
       "      <td>47826612.0</td>\n",
       "      <td>716.0</td>\n",
       "      <td>16.62</td>\n",
       "      <td>...</td>\n",
       "      <td>957451648.0</td>\n",
       "      <td>719.0</td>\n",
       "      <td>16.57</td>\n",
       "      <td>278740531.0</td>\n",
       "      <td>09:54:00</td>\n",
       "      <td>5.0</td>\n",
       "      <td>2593.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.786234</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-05-11 00:00:00</th>\n",
       "      <td>1.099174</td>\n",
       "      <td>300367.XSHE</td>\n",
       "      <td>70.00</td>\n",
       "      <td>70.00</td>\n",
       "      <td>70.00</td>\n",
       "      <td>70.00</td>\n",
       "      <td>70.00</td>\n",
       "      <td>54975.0</td>\n",
       "      <td>271.0</td>\n",
       "      <td>77.00</td>\n",
       "      <td>...</td>\n",
       "      <td>5705390.0</td>\n",
       "      <td>274.0</td>\n",
       "      <td>33.82</td>\n",
       "      <td>0.0</td>\n",
       "      <td>09:30:00</td>\n",
       "      <td>5.0</td>\n",
       "      <td>2027.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.614615</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-05-14 00:00:00</th>\n",
       "      <td>0.867824</td>\n",
       "      <td>300081.XSHE</td>\n",
       "      <td>61.90</td>\n",
       "      <td>61.90</td>\n",
       "      <td>61.90</td>\n",
       "      <td>60.00</td>\n",
       "      <td>61.50</td>\n",
       "      <td>2574902.0</td>\n",
       "      <td>757.0</td>\n",
       "      <td>68.09</td>\n",
       "      <td>...</td>\n",
       "      <td>6562712.0</td>\n",
       "      <td>760.0</td>\n",
       "      <td>28.39</td>\n",
       "      <td>5013924.0</td>\n",
       "      <td>09:37:00</td>\n",
       "      <td>5.0</td>\n",
       "      <td>1097.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.332626</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-05-20 00:00:00</th>\n",
       "      <td>1.051849</td>\n",
       "      <td>002637.XSHE</td>\n",
       "      <td>25.03</td>\n",
       "      <td>25.03</td>\n",
       "      <td>25.03</td>\n",
       "      <td>25.03</td>\n",
       "      <td>25.03</td>\n",
       "      <td>34663.0</td>\n",
       "      <td>769.0</td>\n",
       "      <td>27.53</td>\n",
       "      <td>...</td>\n",
       "      <td>24003892.0</td>\n",
       "      <td>772.0</td>\n",
       "      <td>14.33</td>\n",
       "      <td>5964741.0</td>\n",
       "      <td>09:31:00</td>\n",
       "      <td>5.0</td>\n",
       "      <td>434.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.131595</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-05-27 00:00:00</th>\n",
       "      <td>1.099960</td>\n",
       "      <td>300173.XSHE</td>\n",
       "      <td>62.50</td>\n",
       "      <td>62.50</td>\n",
       "      <td>62.50</td>\n",
       "      <td>62.50</td>\n",
       "      <td>62.50</td>\n",
       "      <td>99200.0</td>\n",
       "      <td>754.0</td>\n",
       "      <td>68.75</td>\n",
       "      <td>...</td>\n",
       "      <td>21172844.0</td>\n",
       "      <td>757.0</td>\n",
       "      <td>24.28</td>\n",
       "      <td>7217886.0</td>\n",
       "      <td>09:31:00</td>\n",
       "      <td>5.0</td>\n",
       "      <td>978.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.296543</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-07-21 00:00:00</th>\n",
       "      <td>1.086379</td>\n",
       "      <td>002173.XSHE</td>\n",
       "      <td>17.41</td>\n",
       "      <td>17.41</td>\n",
       "      <td>17.41</td>\n",
       "      <td>17.41</td>\n",
       "      <td>17.41</td>\n",
       "      <td>330982.0</td>\n",
       "      <td>717.0</td>\n",
       "      <td>19.15</td>\n",
       "      <td>...</td>\n",
       "      <td>13793779.0</td>\n",
       "      <td>720.0</td>\n",
       "      <td>19.30</td>\n",
       "      <td>8996200.0</td>\n",
       "      <td>09:35:00</td>\n",
       "      <td>5.0</td>\n",
       "      <td>277.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.083990</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-07-22 00:00:00</th>\n",
       "      <td>1.040125</td>\n",
       "      <td>600363.XSHG</td>\n",
       "      <td>13.18</td>\n",
       "      <td>13.18</td>\n",
       "      <td>13.18</td>\n",
       "      <td>13.18</td>\n",
       "      <td>13.18</td>\n",
       "      <td>950865.0</td>\n",
       "      <td>858.0</td>\n",
       "      <td>14.50</td>\n",
       "      <td>...</td>\n",
       "      <td>113796816.0</td>\n",
       "      <td>861.0</td>\n",
       "      <td>15.41</td>\n",
       "      <td>14451766.0</td>\n",
       "      <td>09:31:00</td>\n",
       "      <td>5.0</td>\n",
       "      <td>1484.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.449970</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-10-28 00:00:00</th>\n",
       "      <td>0.993965</td>\n",
       "      <td>002432.XSHE</td>\n",
       "      <td>23.28</td>\n",
       "      <td>23.28</td>\n",
       "      <td>23.28</td>\n",
       "      <td>23.28</td>\n",
       "      <td>23.28</td>\n",
       "      <td>3433808.0</td>\n",
       "      <td>919.0</td>\n",
       "      <td>25.61</td>\n",
       "      <td>...</td>\n",
       "      <td>94767520.0</td>\n",
       "      <td>922.0</td>\n",
       "      <td>27.20</td>\n",
       "      <td>19149200.0</td>\n",
       "      <td>09:34:00</td>\n",
       "      <td>5.0</td>\n",
       "      <td>2052.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.622195</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-12-04 00:00:00</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>600338.XSHG</td>\n",
       "      <td>18.36</td>\n",
       "      <td>18.36</td>\n",
       "      <td>18.36</td>\n",
       "      <td>18.36</td>\n",
       "      <td>18.36</td>\n",
       "      <td>505900.0</td>\n",
       "      <td>744.0</td>\n",
       "      <td>20.20</td>\n",
       "      <td>...</td>\n",
       "      <td>32964773.0</td>\n",
       "      <td>747.0</td>\n",
       "      <td>19.63</td>\n",
       "      <td>14736400.0</td>\n",
       "      <td>10:05:00</td>\n",
       "      <td>5.0</td>\n",
       "      <td>561.5</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.170255</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-03-07 00:00:00</th>\n",
       "      <td>0.915503</td>\n",
       "      <td>000029.XSHE</td>\n",
       "      <td>11.84</td>\n",
       "      <td>11.84</td>\n",
       "      <td>11.84</td>\n",
       "      <td>11.84</td>\n",
       "      <td>11.84</td>\n",
       "      <td>4845529.0</td>\n",
       "      <td>1028.0</td>\n",
       "      <td>13.02</td>\n",
       "      <td>...</td>\n",
       "      <td>71313742.0</td>\n",
       "      <td>1031.0</td>\n",
       "      <td>12.78</td>\n",
       "      <td>48846400.0</td>\n",
       "      <td>10:11:00</td>\n",
       "      <td>5.0</td>\n",
       "      <td>2303.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.698302</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-04-05 00:00:00</th>\n",
       "      <td>1.049204</td>\n",
       "      <td>000913.XSHE</td>\n",
       "      <td>11.42</td>\n",
       "      <td>11.42</td>\n",
       "      <td>11.42</td>\n",
       "      <td>11.42</td>\n",
       "      <td>11.42</td>\n",
       "      <td>1120400.0</td>\n",
       "      <td>1017.0</td>\n",
       "      <td>12.56</td>\n",
       "      <td>...</td>\n",
       "      <td>71647243.0</td>\n",
       "      <td>1020.0</td>\n",
       "      <td>12.27</td>\n",
       "      <td>35674500.0</td>\n",
       "      <td>10:24:00</td>\n",
       "      <td>5.0</td>\n",
       "      <td>1553.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.470891</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-12-09 00:00:00</th>\n",
       "      <td>1.081347</td>\n",
       "      <td>601116.XSHG</td>\n",
       "      <td>33.63</td>\n",
       "      <td>33.63</td>\n",
       "      <td>33.63</td>\n",
       "      <td>30.05</td>\n",
       "      <td>30.57</td>\n",
       "      <td>20595234.0</td>\n",
       "      <td>1205.0</td>\n",
       "      <td>36.99</td>\n",
       "      <td>...</td>\n",
       "      <td>34372264.0</td>\n",
       "      <td>1208.0</td>\n",
       "      <td>36.41</td>\n",
       "      <td>16625438.0</td>\n",
       "      <td>09:46:00</td>\n",
       "      <td>5.0</td>\n",
       "      <td>2589.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.785021</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>26 rows × 38 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                       change        stock  close0  high0  high_limit0   low0  \\\n",
       "date                                                                            \n",
       "2007-07-23 00:00:00  1.028160  600617.XSHG   12.62  12.62        12.62  11.70   \n",
       "2008-12-18 00:00:00  1.000000  600397.XSHG    4.31   4.31         4.31   4.31   \n",
       "2012-03-16 00:00:00  1.080107  600300.XSHG    6.19   6.19         6.19   5.82   \n",
       "2012-04-24 00:00:00  1.087137  600606.XSHG    7.96   7.96         7.96   6.93   \n",
       "2012-08-08 00:00:00  0.960000  002070.XSHE    9.30   9.30         9.30   8.60   \n",
       "2013-08-29 00:00:00  1.209246  600018.XSHG    3.40   3.40         3.40   3.22   \n",
       "2014-07-15 00:00:00  1.058366  002212.XSHE    6.37   6.37         6.37   6.37   \n",
       "2014-09-12 00:00:00  1.055061  300242.XSHE   25.06  25.06        25.06  25.06   \n",
       "2014-09-19 00:00:00  1.058879  600260.XSHG    8.70   8.70         8.70   8.70   \n",
       "2015-01-06 00:00:00  0.827023  600379.XSHG   12.66  12.66        12.66  12.66   \n",
       "2015-03-11 00:00:00  1.073171  300081.XSHE   33.88  33.88        33.88  33.01   \n",
       "2015-04-03 00:00:00  1.045057  002356.XSHE   69.88  69.88        69.88  64.25   \n",
       "2015-04-13 00:00:00  1.051472  300388.XSHE   82.53  82.53        82.53  82.53   \n",
       "2015-04-14 00:00:00  1.100000  000819.XSHE   40.16  40.16        40.16  36.23   \n",
       "2015-04-30 00:00:00  1.074398  601669.XSHG   15.11  15.11        15.11  15.11   \n",
       "2015-05-11 00:00:00  1.099174  300367.XSHE   70.00  70.00        70.00  70.00   \n",
       "2015-05-14 00:00:00  0.867824  300081.XSHE   61.90  61.90        61.90  60.00   \n",
       "2015-05-20 00:00:00  1.051849  002637.XSHE   25.03  25.03        25.03  25.03   \n",
       "2015-05-27 00:00:00  1.099960  300173.XSHE   62.50  62.50        62.50  62.50   \n",
       "2015-07-21 00:00:00  1.086379  002173.XSHE   17.41  17.41        17.41  17.41   \n",
       "2015-07-22 00:00:00  1.040125  600363.XSHG   13.18  13.18        13.18  13.18   \n",
       "2015-10-28 00:00:00  0.993965  002432.XSHE   23.28  23.28        23.28  23.28   \n",
       "2015-12-04 00:00:00  1.000000  600338.XSHG   18.36  18.36        18.36  18.36   \n",
       "2016-03-07 00:00:00  0.915503  000029.XSHE   11.84  11.84        11.84  11.84   \n",
       "2016-04-05 00:00:00  1.049204  000913.XSHE   11.42  11.42        11.42  11.42   \n",
       "2016-12-09 00:00:00  1.081347  601116.XSHG   33.63  33.63        33.63  30.05   \n",
       "\n",
       "                     open0      volume0    day0  close1  ...        volume3  \\\n",
       "date                                                     ...                  \n",
       "2007-07-23 00:00:00  12.30    3241958.0   103.0   13.88  ...      3742741.0   \n",
       "2008-12-18 00:00:00   4.31    5719937.0   448.0    4.74  ...     22304664.0   \n",
       "2012-03-16 00:00:00   6.19   51342868.0    66.0    6.81  ...    188746336.0   \n",
       "2012-04-24 00:00:00   6.99   62181380.0    91.0    8.76  ...     38214496.0   \n",
       "2012-08-08 00:00:00   8.68   29633210.0   147.0   10.23  ...     33007452.0   \n",
       "2013-08-29 00:00:00   3.29  113849456.0   418.0    3.74  ...     79742536.0   \n",
       "2014-07-15 00:00:00   6.37    4833381.0   628.0    7.01  ...     82380808.0   \n",
       "2014-09-12 00:00:00  25.06     779450.0   581.0   27.57  ...      4093207.0   \n",
       "2014-09-19 00:00:00   8.70    3975731.0   602.0    9.57  ...    116226864.0   \n",
       "2015-01-06 00:00:00  12.66     479546.0   504.0   13.93  ...     22347056.0   \n",
       "2015-03-11 00:00:00  33.88    9387742.0   722.0   37.27  ...     24823688.0   \n",
       "2015-04-03 00:00:00  64.90    3867932.0   649.0   76.87  ...      9805463.0   \n",
       "2015-04-13 00:00:00  82.53     234151.0   163.0   90.78  ...     11206967.0   \n",
       "2015-04-14 00:00:00  36.23    5321822.0   810.0   44.18  ...     18363148.0   \n",
       "2015-04-30 00:00:00  15.11   47826612.0   716.0   16.62  ...    957451648.0   \n",
       "2015-05-11 00:00:00  70.00      54975.0   271.0   77.00  ...      5705390.0   \n",
       "2015-05-14 00:00:00  61.50    2574902.0   757.0   68.09  ...      6562712.0   \n",
       "2015-05-20 00:00:00  25.03      34663.0   769.0   27.53  ...     24003892.0   \n",
       "2015-05-27 00:00:00  62.50      99200.0   754.0   68.75  ...     21172844.0   \n",
       "2015-07-21 00:00:00  17.41     330982.0   717.0   19.15  ...     13793779.0   \n",
       "2015-07-22 00:00:00  13.18     950865.0   858.0   14.50  ...    113796816.0   \n",
       "2015-10-28 00:00:00  23.28    3433808.0   919.0   25.61  ...     94767520.0   \n",
       "2015-12-04 00:00:00  18.36     505900.0   744.0   20.20  ...     32964773.0   \n",
       "2016-03-07 00:00:00  11.84    4845529.0  1028.0   13.02  ...     71313742.0   \n",
       "2016-04-05 00:00:00  11.42    1120400.0  1017.0   12.56  ...     71647243.0   \n",
       "2016-12-09 00:00:00  30.57   20595234.0  1205.0   36.99  ...     34372264.0   \n",
       "\n",
       "                       day3  minute_low  minute_volume    minute  recent  \\\n",
       "date                                                                       \n",
       "2007-07-23 00:00:00   106.0        8.38       531770.0  09:33:00     5.0   \n",
       "2008-12-18 00:00:00   451.0        2.07     18253344.0  09:47:00     5.0   \n",
       "2012-03-16 00:00:00    69.0        6.83     11783973.0  10:31:00     5.0   \n",
       "2012-04-24 00:00:00    94.0        8.32     19988191.0  09:35:00     5.0   \n",
       "2012-08-08 00:00:00   150.0        8.65            0.0  09:30:00     5.0   \n",
       "2013-08-29 00:00:00   421.0        3.80            0.0  09:30:00     5.0   \n",
       "2014-07-15 00:00:00   631.0        7.48            0.0  09:30:00     5.0   \n",
       "2014-09-12 00:00:00   584.0        6.06            0.0  09:30:00     5.0   \n",
       "2014-09-19 00:00:00   605.0        9.57     29786674.0  09:41:00     5.0   \n",
       "2015-01-06 00:00:00   507.0       14.55      6670200.0  09:33:00     5.0   \n",
       "2015-03-11 00:00:00   725.0       16.36            0.0  09:30:00     5.0   \n",
       "2015-04-03 00:00:00   652.0       26.76      3074653.0  09:33:00     5.0   \n",
       "2015-04-13 00:00:00   166.0       32.10      2351834.0  09:31:00     5.0   \n",
       "2015-04-14 00:00:00   813.0       43.96            0.0  09:30:00     5.0   \n",
       "2015-04-30 00:00:00   719.0       16.57    278740531.0  09:54:00     5.0   \n",
       "2015-05-11 00:00:00   274.0       33.82            0.0  09:30:00     5.0   \n",
       "2015-05-14 00:00:00   760.0       28.39      5013924.0  09:37:00     5.0   \n",
       "2015-05-20 00:00:00   772.0       14.33      5964741.0  09:31:00     5.0   \n",
       "2015-05-27 00:00:00   757.0       24.28      7217886.0  09:31:00     5.0   \n",
       "2015-07-21 00:00:00   720.0       19.30      8996200.0  09:35:00     5.0   \n",
       "2015-07-22 00:00:00   861.0       15.41     14451766.0  09:31:00     5.0   \n",
       "2015-10-28 00:00:00   922.0       27.20     19149200.0  09:34:00     5.0   \n",
       "2015-12-04 00:00:00   747.0       19.63     14736400.0  10:05:00     5.0   \n",
       "2016-03-07 00:00:00  1031.0       12.78     48846400.0  10:11:00     5.0   \n",
       "2016-04-05 00:00:00  1020.0       12.27     35674500.0  10:24:00     5.0   \n",
       "2016-12-09 00:00:00  1208.0       36.41     16625438.0  09:46:00     5.0   \n",
       "\n",
       "                     circap  isnew      capq     st  \n",
       "date                                                 \n",
       "2007-07-23 00:00:00    17.0    0.0  0.005155  False  \n",
       "2008-12-18 00:00:00   509.5    0.0  0.154488  False  \n",
       "2012-03-16 00:00:00  2147.0    0.0  0.651001  False  \n",
       "2012-04-24 00:00:00  1801.0    0.0  0.546089  False  \n",
       "2012-08-08 00:00:00  1797.0    0.0  0.544876  False  \n",
       "2013-08-29 00:00:00  2444.0    0.0  0.741055  False  \n",
       "2014-07-15 00:00:00   850.0    0.0  0.257732  False  \n",
       "2014-09-12 00:00:00    58.0    0.0  0.017586  False  \n",
       "2014-09-19 00:00:00  1696.0    0.0  0.514251  False  \n",
       "2015-01-06 00:00:00   998.0    0.0  0.302608  False  \n",
       "2015-03-11 00:00:00   888.0    0.0  0.269254  False  \n",
       "2015-04-03 00:00:00  1474.0    0.0  0.446938  False  \n",
       "2015-04-13 00:00:00   281.0    0.0  0.085203  False  \n",
       "2015-04-14 00:00:00  1936.0    0.0  0.587022  False  \n",
       "2015-04-30 00:00:00  2593.0    0.0  0.786234  False  \n",
       "2015-05-11 00:00:00  2027.0    0.0  0.614615  False  \n",
       "2015-05-14 00:00:00  1097.0    0.0  0.332626  False  \n",
       "2015-05-20 00:00:00   434.0    0.0  0.131595  False  \n",
       "2015-05-27 00:00:00   978.0    0.0  0.296543  False  \n",
       "2015-07-21 00:00:00   277.0    0.0  0.083990  False  \n",
       "2015-07-22 00:00:00  1484.0    0.0  0.449970  False  \n",
       "2015-10-28 00:00:00  2052.0    0.0  0.622195  False  \n",
       "2015-12-04 00:00:00   561.5    0.0  0.170255  False  \n",
       "2016-03-07 00:00:00  2303.0    0.0  0.698302  False  \n",
       "2016-04-05 00:00:00  1553.0    0.0  0.470891  False  \n",
       "2016-12-09 00:00:00  2589.0    0.0  0.785021  False  \n",
       "\n",
       "[26 rows x 38 columns]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sub_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
